package com.memory.modules.business.service.record.impl;

import com.memory.common.data.PageSort;
import com.memory.modules.business.domain.earn.CurDayPrice;
import com.memory.modules.business.domain.record.WithdrawRecord;
import com.memory.modules.business.repository.record.WithdrawRecordRepository;
import com.memory.modules.business.service.record.WithdrawRecordService;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Service
public class WithdrawRecordServiceImpl implements WithdrawRecordService {
    @Resource
    private WithdrawRecordRepository withdrawRecordRepository;

    @Override
    public Page<WithdrawRecord> findPage(Example<WithdrawRecord> example) {
        final PageRequest pageRequest = PageSort.pageRequest();
        return withdrawRecordRepository.findAll(example, pageRequest);
    }

    @Override
    public boolean flag(Long id) {
        WithdrawRecord withdrawRecord = withdrawRecordRepository.findById(id).get();
        withdrawRecord.setDispose(1);
        withdrawRecord.setModifyTime(new Date());
        withdrawRecordRepository.save(withdrawRecord);
        return true;
    }
}
